package com.anysoft.douyinApi;

import com.anysoft.douyinApi.model.EnterpriseMsgCard.MsgCardResponse;
import com.anysoft.utility.HttpHelper;

/**
 * 企业号开放平台API
 */
public class EnterpriseOpenAPI {
    private static final String API_DOMAIN = "https://open.douyin.com";

    /**
     * 获取消息卡片列表（不带页码）
     *
     * @param openId      open_id
     * @param accessToken access_token
     * @param count       每页数量
     * @return 消息卡片列表
     */
    public static MsgCardResponse getMessageCardList(String openId, String accessToken, long count) {
        String url = API_DOMAIN + "/enterprise/im/card/list/";
        url += String.format("?open_id=%s&access_token=%s&count=%d", openId, accessToken, count);
        String res = HttpHelper.requestApiForGet(url, "", 15);
        MsgCardResponse response = new MsgCardResponse();
        // todo：将res反序列化为MsgCardResponse对象（response）
        return response;
    }

    /**
     * 获取消息卡片列表（带页码）
     *
     * @param openId      open_id
     * @param accessToken access_token
     * @param count       每页数量
     * @param cursor      第几页
     * @return 消息卡片列表
     */
    public static MsgCardResponse getMessageCardList(String openId, String accessToken, long count, long cursor) {
        String url = API_DOMAIN + "/enterprise/im/card/list/";
        url += String.format("?open_id=%s&access_token=%s&count=%d", openId, accessToken, count);
        if (cursor > -1) {
            url += "&cursor=" + cursor;
        }
        String res = HttpHelper.requestApiForGet(url, "", 15);
        MsgCardResponse response = new MsgCardResponse();
        // todo：将res反序列化为MsgCardResponse对象（response）
        return response;
    }
}
